package com.ljsw.util;

import android.content.Context;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;
import com.ljsw.entity.pkentity.ListMoney;

import java.util.List;

public class SpinnerAdapterHX extends BaseAdapter {
	private Context context;
	private List<ListMoney> list;
	private LayoutInflater layoutInflater;
	private ViewHolder viewHolder = null;
	private int size;


	public SpinnerAdapterHX(Context context, List<ListMoney> list, int size) {
		super();
		// LR_TODO: 2020/4/16 16:36 liu_rui 看了下好像字体大小都是 40
		Log.e("liu_rui", "SpinnerAdapter: Size: " + size);
		this.context = context;
		this.list = list;
		this.size = size;
		layoutInflater = LayoutInflater.from(context);

	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return list.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = layoutInflater.inflate(R.layout.spinner_title, null);
			viewHolder = new ViewHolder();
			convertView.setTag(viewHolder);
			viewHolder.tv = (TextView) convertView.findViewById(R.id.spinner_tv);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.tv.setText(list.get(position).getMoneytype());
		viewHolder.tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size);
		return convertView;
	}

	public static class ViewHolder {
		public TextView tv;
	}

}